<#include
        "/common/coms.html"  /> <@layout>
<!-- ace styles -->
<link rel="stylesheet" href="${ctx}/static/assets/css/ace.min.css" />
        <script src='${ctx}/static/js/validator.js' type='text/javascript'></script>
    <script src="${ctx}/static/inc/platform/js/ajax.js"></script>
    <link rel="stylesheet" href="${ctx}/static/kindeditor/themes/default/default.css" />
    <script charset="utf-8" src="${ctx}/static/kindeditor/kindeditor-min.js"></script>
    <script charset="utf-8" src="${ctx}/static/kindeditor/lang/zh_CN.js"></script>
    <script charset="utf-8" src="${ctx}/static/kindeditor/plugins/code/prettify.js"></script>

<script type="text/javascript">

    function saveModel() {
        if(Validator.Validate(document.getElementById('form1'))){
        } else {
            return;
        }
//       var m=$("#nr").val();
//        m = m.replace(/(\t)/g, "");
//       m = m.replace(/(\n)/g, "");
//        alert(m);
////        $("#xmjj").attr("value",m);
// 同步数据后可以直接取得textarea的value
        var id=document.getElementById("id").value;
        url = '';
        if(id==""){
            url = '${ctx}/mb/savelb';
        }     else{
            url = '${ctx}/mb/updatelb';
        }
        $('#form1').form('submit', {
            url : url,
            onSubmit : function() {
                return $(this).form('validate');
            },
            success : function(data) {
                alert(data);
                parent.parent.location.reload();
            }
        });

    }
</script>
<body>
<div class="page-header"  style="overflow: hidden">

    <div class="row-fluid">
        <div class="span12">
            <!-- PAGE CONTENT BEGINS -->
            <div class="tabbable tabs-left">
                <form class="form-horizontal"  id="form1" method="post" >
                    <table class="table table-condensed table-bordered">
                        <tbody>
                              <tr class="info">
                            <td>
                                上级类别名称：
                            </td>
                            <td >${name}
                                <input type="hidden" name="id" id="id" style="min-height: 24px;" >
                                <input type="hidden" name="sj_lbid" id="sj_lbid" style="min-height: 24px;" value="${lbid}">
                            </td>
                        </tr>
                         <tr class="info">
                            <td>
                                模板名称：
                            </td>
                            <td>
                                <input id="mbmc" name="mbmc" type="text"  style="min-height: 24px;"  dataType="Require" msg="请输入模板名称"  maxlength="20"  />
                            </td>
                        </tr>
                          <tr class="info">
                            <td colspan="2">
                                模板路径统一在
                                /WebRoot/WEB-INF/view/weixin/temp 下面 
                            </td>
                        </tr>
                        <tr class="info">
                            <td>
                                模板路径（只输入文件名称如 index.html）：
                            </td>
                            <td>
                                <input id="mburl" name="mburl" type="text"  style="min-height: 24px;"    maxlength="150"  />
                            </td>
                        </tr>
                       
                        <tr class="info">
                            <td>
                                显示顺序：
                            </td>
                            <td>
                                <input id="dsporder" name="dsporder" type="text"  class="number" style="min-height: 24px;"  />
                            </td>
                        </tr>
                         <tr class="info">
                            <td>
                                是否可以编辑：
                            </td>
                            <td>
                                <select name="bjzt" id="bjzt">
                                    <option value="1" selected>是</option>
                                    <option value="0">否</option>
                                </select>
                            </td>
                        </tr>
                        <tr class="info">
                            <td>
                                有效标志：
                            </td>
                            <td>
                                <select name="yxbz" id="yxbz">
                                    <option value="1" selected>有效</option>
                                    <option value="0">无效</option>
                                </select>
                            </td>
                        </tr>
                               <tr class="info">
                            <td>
                                模板类型：
                            </td>
                            <td>
                                <select name="mblx" id="mblx">
                                    <option value="1" selected>初页式模板</option>
                                    <option value="0">引导式模板</option>
                                </select>
                            </td>
                        </tr>
                            <tr class="info">
                            <td>
                                缩略图片：
                            </td>
                            <td>
                            <input type="text" name ="picurl" id="picurl" style="height:24px"">
                                              <a class="btn btn-info btn-mini"  id="image1" >选择图片 </a>（本地上传）
                            </td>
                        </tr>
                            <tr class="info">
                            <td>
                                背景音乐：
                            </td>
                            <td>
                            <input type="text" name ="music" id="music" style="height:24px"">
                                              <a class="btn btn-info btn-mini"  id="musics" >选择音乐 </a>（本地上传）
                            </td>
                        </tr>
                        <tr class="info">
                            <td colspan="4" style="text-align: center">
                                <a href="#"  class="btn btn-info btn-small" onclick="saveModel()"   >确定 </a>
                                &nbsp; &nbsp;&nbsp;&nbsp;
                                <a href="#"  class="btn btn-danger btn-small bigger-110"  onclick="parent.closeDialog();"  >取消 </a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>

        </div>

    </div>
</div>

</body>


<script>
    <#list list as m>
      document.getElementById("id").value  = '${(m.id)!}';
    document.getElementById("mbmc").value  =  '${(m.mbmc)!}';
    document.getElementById("mburl").value  =  '${(m.mburl)!}';
    document.getElementById("sj_lbid").value  =  '${(m.sj_lbid)!}';

    document.getElementById("yxbz").value  =  '${(m.yxbz)!}';
    document.getElementById("dsporder").value  =  '${(m.dsporder)!}';
    document.getElementById("bjzt").value  =  '${(m.bjzt)!}';
    document.getElementById("picurl").value  =  '${(m.picurl)!}';

    </#list>
    KindEditor.ready(function(K) {
        var editor = K.editor({
            cssPath : '${ctx}/static/kindeditor/plugins/code/prettify.css',
            uploadJson : '${ctx}/upload/upload/',
            fileManagerJson : '${ctx}/upload/manageImg',
            allowFileManager : true
        });
        K('#image1').click(function() {
            editor.loadPlugin('image', function() {
                editor.plugin.imageDialog({
                    showRemote : false,
                    clickFn : function(url, title, width, height, border, align) {
                    		$("#picurl").attr("value",url);
            /*         	var htm="<li id='li"+width+"'> <a  data-rel='colorbox'>"+
    				 "  <img  src='"+url+"'   style='width:100px;height:100px;'/><div class='text'>"+
                     "<div class='inner'>"+title+"</div>   </div></a>"+
                     "<div class='tools tools-bottom'>"+
                     "<a href='#' onclick=\"dels('"+url+"','"+width+"')\" >  "+
                     "<i class='icon-remove red  '></i></a></div> </li>"; */
                        editor.hideDialog();
                    }
                });
            });
        });
        
      
        
        var uploadbutton = K.uploadbutton({
			button : K('#musics'),
			fieldName : 'imgFile',
			url : '${ctx}/upload/upload?dir=media',
			afterUpload :function(data) {
				if (data.error === 0) {
					var url = K.formatUrl(data.url, 'absolute');
            		$("#music").attr("value",url);
				} else {
					alert(data.message);
				}
			},
			afterError : function(str) {
				alert('自定义错误信息: ' + str);
			}
		});
		uploadbutton.fileBox.change(function(e) {
			uploadbutton.submit();
		});

    });
		
</script>
</@layout>

